package com.jxc.jxc01.grc.web;

import com.jxc.jxc01.grc.entity.Vendor;
import com.jxc.jxc01.grc.service.IVendorService;
import com.jxc.jxc01.grc.service.impl.VendorServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(value = "/reviseVendor")
public class ReviseVendorServlet extends HttpServlet {
    IVendorService vendorService = new VendorServiceImpl();
    @Override
    protected void service(HttpServletRequest request,
                           HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utc-8");

        IVendorService vendorService = new VendorServiceImpl();
        int id = Integer.parseInt(request.getParameter("id"));
        String name = request.getParameter("suppliername");
        String head = request.getParameter("headname");
        String phone = request.getParameter("phone");
        String address = request.getParameter("address");
        String bank = request.getParameter("bank");
//        String creationtime = request.getParameter("Creationtime");
        String updatetime = request.getParameter("updatetime");

        Vendor vendor = new Vendor();
        vendor.setId(id);
        vendor.setSuppliername(name);
        vendor.setHeadname(head);
        vendor.setPhone(phone);
        vendor.setAddress(address);
        vendor.setBank(bank);
//        vendor.setCreationtime(creationtime);
        vendor.setUpdatetime(updatetime);
        vendorService.reviseVendor(vendor);
    }
}
